package com.deo.freemark.util;

import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;

public class Demo01 {

	public static void main(String[] args) throws Exception {
		Configuration cfg = new Configuration();
		StringTemplateLoader stringLoader = new StringTemplateLoader();
		String templateContent = "${6-(8-6)*8}";
		stringLoader.putTemplate("myTemplate", templateContent);
		cfg.setTemplateLoader(stringLoader);
		Template template = cfg.getTemplate("myTemplate", "utf-8");
		Map<String, Object> root = new HashMap<String, Object>();
		StringWriter writer = new StringWriter();
		template.process(root, writer);
		System.out.println(writer.toString());

	}

}
